#pragma once
#include "../CGIPrefix.h"

namespace Alice
{
    class VulkanDevice;
    class VulkanFence
    {
    public:
        enum class EState
        {
            // Initial state
            NotReady,
            // After GPU processed it
            Signaled,
        };
        VulkanDevice* mVulkanDevice;
        VkFence mFence;
        EState mState;
        VulkanFence(VulkanDevice*inVulkanDevice,bool inbCreateSignaled);
        ~VulkanFence();
        inline VkFence GetHandle() const
        {
            return mFence;
        }
        inline bool IsSignaled() const
        {
            return mState==EState::Signaled;
        }
        void Reset();
    };
    class FenceManager
    {
    public:
        FenceManager();
        void Init(VulkanDevice*inDevice);
        VulkanFence* AllocateFence(bool bCreateSignaled = false);
        VulkanDevice* mDevice;
        bool WaitForFence(VulkanFence* inFence, uint64 inTimeInNanoseconds=UINT64_MAX) const;
    };
}
